<template>
  <div id="app">
    <login v-if="!isLogin && isShowLogin"></login>
    <sidebarInfo style="flex: 0 0 160px;" />
    <main>
      <div class="top-content">
        <top-view></top-view>
      </div>
      <div class="main-content">
        <router-view></router-view>
      </div>
    </main>
  </div>
</template>

<script>
import sidebarInfo from './components/sidebarInfo.vue'
import TopView from './components/TopView.vue'
import login from './components/login.vue'
import api from './api/axios.js'

export default {
  name: 'App',
  components: {
    sidebarInfo,
    TopView,
    login
  },
  computed: {
    isLogin: {
      get() { return this.$store.state.user.isLogin }
    },
    isShowLogin: {
      get() { return this.$store.state.user.isShowLogin }
    }
  },
  data() {
    return {
      fullWidth: document.documentElement.clientWidth,
      fullHeight: document.documentElement.clientHeight
    }
  },
  mounted() {
    api.isLogin()
    .then((response) => {
      if (response.data.code === '200' && response.data.type === 'isLogin') {
        this.$store.state.user.isLogin = true
        this.$store.state.user.author_name = response.data.data.author_name
        this.$store.state.user.avatar_url = response.data.data.avatar_url
        this.$store.state.user.user_id = response.data.data.user_id
      }
    })
    .catch(() => {
      console.log('连接失败！')
    })
  }
}
</script>

<style>
#app {
  width: 100%;
  height: 100%;
  display: flex;
  background: linear-gradient(
    135deg,
    #1a1a2e 0%,
    #16213e 50%,
    #1a1a2e 100%
  );
  position: relative;
  overflow: hidden;
}

/* 添加动态背景效果 */
#app::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(255, 44, 85, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 15% 70%, rgba(63, 94, 251, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* 确保内容在背景之上 */
#app > * {
  position: relative;
  z-index: 1;
}

/* 添加毛玻璃效果的卡片背景 */
.el-card, .chat-container, .friend-list {
  background: rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* 优化滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

::-webkit-scrollbar-track {
  background: transparent;
}

main{
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100% - 10px);
}

.top-content{
  width: 95%;
  height: 68px;
}

.main-content{
  width: 100%;
  flex-grow: 1;
  flex-shrink: 1;
  overflow: auto;
  position: relative;
  padding:0 10px;
}

/* 滚动条整体样式 */
.main-content::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.main-content::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom right, rgb(22, 24, 35) 0%, rgb(22, 24, 35) 100%);
  border-radius: 5px;
}

.main-content::-webkit-scrollbar-track {
  background-color: transparent;
}

/* 向下箭头按钮样式 */
.main-content::-webkit-scrollbar-button:start:decrement {
  width: 5px;
  height: 5px;
  border-radius: 2.5px;
  background-color: rgb(22, 24, 35);
}

/* 向上箭头按钮样式 */
.main-content::-webkit-scrollbar-button:end:increment {
  width: 5px;
  height: 5px;
  border-radius: 2.5px;
  background-color: rgb(22, 24, 35);
}

.main-content::-webkit-scrollbar-button:hover {
  cursor: pointer;
}
</style>
